<?php
function DefineLang(){
	global $_local_lang_arr;
	if(isset($_POST['change_lang']) && in_array($_POST['change_lang'], $_local_lang_arr)){
		$_SESSION['lang'] = $_POST['change_lang'];
	}
	if(!isset($_SESSION['lang']) || $_SESSION['lang'] == ''){
		$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
		if(in_array($lang, $_local_lang_arr))
			$_SESSION['lang'] = $lang;
		else 
			$_SESSION['lang'] = DEF_LANG;
	}
}
function getLangLabels($file) {
    $file_dat = SITELANGDIR.$file.'.dat';
    if (!file_exists($file_dat) || filemtime($file_dat) <= filemtime(SITELANGDIR.$file.'.php')) {

        $r = include(SITELANGDIR.$file.'.php');
        if ($F = fopen($file_dat, "w")) {
            fwrite($F, serialize($r));
            fclose($F);
        }else{
		echo 'Please give right permissions for '.SITELANGDIR.' folder';exit();
	}
    } else {
        $r = unserialize(file_get_contents($file_dat));
    }
    return $r;
}
?>
